// 收货地址
const addressModule = {
    namespaced: true,
    state: {
        list: [
            {
                id: "1",
                name: "张三",
                tel: "13000000000",
                address: "浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室",
                isDefault: true
              }
        ]
    },
    getters: {
        // 地址列表
        addressList: state => state.list
    },
    mutations: {
        /**
         * 
         * @param {*} state 
         * @param {*} payload {id,name,tel,address}
         */
        addAdress(state, payload) {
            const { addressDetail, areaCode, city, isDefault, name, tel, province,county } = payload
            const theAddress = {
                address:  province +city + county + addressDetail,
                id: areaCode,
                tel,name,isDefault
            }
            // push新的地址到list
            state.list.push(theAddress);
            console.log('store中添加的地址列表',state.list);

        }
    }
}
export default addressModule


// 当前选中的id  
 /* 
 应该是默认是数组中的第一个数据的id
 */